#ifndef SQLMANAGEMENT_H
#define SQLMANAGEMENT_H

#include <cppconn/prepared_statement.h>
#include <cppconn/resultset.h>
#include <QString>
#include <QDebug>
#include <QVariant>
#include <QObject>
#include <mysql_driver.h>
#include <mysql_connection.h>

#include "Logger.hpp"

enum QueryType
{
    PatientID,
    PatientDetails,
    DoctorDetails,
    InstructionDetails,
    PrescriptionDetails,
    MedicalRecordDetails,
    AdviceIdDetails
};

class SQLManagement : public QObject
{
    Q_OBJECT
public:
    SQLManagement();
    SQLManagement(const QString &host, const QString &user, const QString &password, const QString &database);

    ~SQLManagement();

    bool connect();
    void disconnect();
    bool executeQuery(const QString &query);
    QVariant executeQuerySingleResult(const QString &query);
    QVariantMap executeQueryResult(const QString &query, const QString &identity = "");
    QVariantList executeQueryResultList(const QString &query, const QString &profession);
    QVariantList executeQueryResultList(const QString &query, QueryType type);
private:
    QString host;
    QString database;
    QString user;
    QString password;
    sql::Driver* driver;
    sql::Connection *con;
};

#endif // SQLMANAGEMENT_H
